/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.web30.mobile.view.news;

import com.sun.syndication.feed.synd.SyndContentImpl;
import com.sun.syndication.feed.synd.SyndEntry;
import java.io.UnsupportedEncodingException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author xiazy
 */
public class Entry {
    private SyndEntry _entry;
    private int _index ;

    public SyndEntry getEntry() {
        return _entry;
    }

    public void setEntry(SyndEntry _entry) {
        this._entry = _entry;
    }

    public int getIndex() {
        return _index;
    }

    public void setIndex(int index) {
        this._index = index;
    }
    public Entry(SyndEntry entry, int index){
        this._entry = entry;
        this._index = index;
    }
    public Entry(){
        this._entry = null;
        this._index = -1;
    }

    public String getTitle(){
        try {
            return new String(this._entry.getTitle().getBytes("UTF-8"), "UTF-8");
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(Entry.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }
    public String getAuthor(){
        try {
            return new String(this._entry.getAuthor().getBytes(), "UTF-8");
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(Entry.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }
    public String getLink(){
        return this._entry.getUri();
    }
    public String getContent() {
        try {
            SyndContentImpl content = (SyndContentImpl) this._entry.getContents().get(0);
            return new String(content.getValue().getBytes("UTF-8"), "UTF-8");
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(Entry.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }
}
